<?php

namespace frontend\helpers;

class SitemapHelper
{
    public static function rebuildPagePath($pageCollection)
    {
        for ($i=1; $i <= count($pageCollection); $i++) 
        {
            $pageCollection[$i]['path'] = explode('/', $pageCollection[$i]['path']);
            $newPath = array();
            for ($j=1; $j < count($pageCollection[$i]['path']); $j++) 
            { 
                $newPath[] = $pageCollection[$pageCollection[$i]['path'][$j]]['alias'];
            }
            $pageCollection[$i]['path'] = implode('/', $newPath);
        }
        for ($i=1; $i <= count($pageCollection); $i++) 
        {
            if($pageCollection[$i]['is_draft'] || $pageCollection[$i]['is_hidden'])
            {
                unset($pageCollection[$i]);
            }
        }
        return $pageCollection;
    }
}